package com.u.social.sale.controller;


import com.u.social.sale.entity.Product;
import com.u.social.sale.model.PublicProductDTO;
import com.u.social.sale.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Alex Wu
 * @since 2025-03-05
 */
@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private IProductService productService;

    @PostMapping("")
    public PublicProductDTO create(@RequestBody PublicProductDTO product) {
        return productService.saveProduct(product);
    }

   /* @GetMapping("/{id}")
    public Product getById(@PathVariable Long id) {
        return productService.getById(id);
    }

    @PutMapping("/{id}")
    public Product update(@PathVariable Long id, @RequestBody Product product) {
        product.setId(id);
        return productService.update(product);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        productService.delete(id);
    }

    @GetMapping("/")
    public List<Product> getAll() {
        return productService.getAll();
    }*/

    @GetMapping("/hot-products")
    public List<Product> getHotProducts() {
        return productService.getHotProducts();
    }

}
